class Solution {
    //找出所有子集的异或总和再求和
    public int ret;
    public int sum;
    public int subsetXORSum(int[] nums) {
        ret = 0;
        sum = 0;
        dfs(nums, 0);
        return sum;
    }
    public void dfs(int[] nums, int index){
        sum += ret;
        for(int i = index; i < nums.length; i++){
            ret ^= nums[i];
            dfs(nums, i + 1);
            ret ^= nums[i];//回溯
        }
    }
}